package com.warrant.module.rpa.finance.util;

import java.util.Map;

import org.apache.commons.jexl3.JexlContext;
import org.apache.commons.jexl3.MapContext;

import com.eos.system.annotation.Bizlet;
import com.greenpineyu.fel.context.FelContext;

/**
 * 匹配规则
 * 
 * @author Administrator
 * 
 */
@Bizlet
public class MatchUtil {

	/**
	 * 匹配
	 * 
	 * @param ruleStr
	 * @param map
	 * @return
	 */
	@Bizlet
	public static boolean matchBoolean(String ruleStr, Map<String, Object> map) {
		JexlContext context = new MapContext(map);
		Object result = JexlUtil.execute(ruleStr, context);
		if (result instanceof Boolean) {
			return (Boolean) result;
		}
		return false;
	}
	
	/**
	 * 匹配
	 * 
	 * @param ruleStr
	 * @param map
	 * @return
	 */
	@Bizlet
	public static boolean matchFastBoolean(String ruleStr, Map<String, Object> map) {
		FelContext context = new com.greenpineyu.fel.context.MapContext(map);
		Object result = FastelUtil.execute(ruleStr, context);
		if (result instanceof Boolean) {
			return (Boolean) result;
		}
		return false;
	}
	
	public static void main(String[] args) {
		System.out.println(matchFastBoolean("false",null));
	}

}
